define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_detail(result) {
			if(HTTP_ISLOGIC) {
				result = '{"success": true,"msg": "","result": ' +
						'{"act_id": "001","name": "促销","start_time": "2017/01/01 09:00:00","end_time": "2017/02/01 09:00:00","create_group": true,"has_packets": true,"video_type": "1","image": [{"id": "001","image": ""},{"id": "002","image": ""}],"brand_id": "001","cat_type": [{"id": "001"},{"id": "002"}]},' +
						'"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		function get_data_promotion_detail(result){
			if(false){
				result = '{"success": true,"msg": "","result": {"act_id": "001","act_name": "促销活动","start_time": "2017/01/01 09:00:00","end_time": "2017/01/31 09:00:00","group_id": "123456789","introduction": "这里是双十一促销的简介",'+
        '"image": [{"id": "001","image": ""},{"id": "002","image": ""}],"deal_count": 145,"deal_money": "5698.12","goods_count": 567,"attention_count": 2356},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			}else
			return result;
		}
		function get_data_goods_list(result){
			if(HTTP_ISLOGIC) {
				result = '{"success": true,"msg": "","result": {"store_count": "500","data": [' +
					'{"goods_id": 1,"name": "十字螺丝刀","introduce": "十字螺丝刀","price": 5.5,"mktprice": 8,"preprice": 5.5,"store_id": "WuJin_1",' +
					'"store_name": "五金一店","image": "./img/upload/pro-img01.jpg","storenumber": 100,"salenumber": 20,"personlimit": 3,"qq": "1234567","phone": "18912345678"},' +
					'{"goods_id": 2,"name": "一字螺丝刀","introduce": "一字螺丝刀","price": 5.5,"mktprice": 8,"preprice": 5.5,"store_id": "WuJin_1",' +
					'"store_name": "五金一店","image": "./img/upload/pro-img01.jpg","storenumber": 80,"salenumber": 10,"personlimit": 3,"qq": "1234567","phone": "18912345678"}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else
				return result;
		}

		//返回信息
		return {
			//获取活动详细
			promotion_detail:function(nPage,act_id,as_id,method,callback,calldone){
				Http.post({
					method:method,
					nPage:nPage,
					act_id:act_id,
					as_id:as_id,//8和9用到
					pagelimit:10
				},function(result){
					if(callback)
						callback(get_data_promotion_detail(result));
				},function(e){
					
				},function(){
					if(calldone)
						calldone();
				})
			},
			get_loginfo:function(callback){
				Http.post({
					method:'chat.group.getlogininfo'
				},function(result){
					if(callback)
					callback(result.result);
				})
			},
			join_group:function(group_id,callback){
				Http.post({
					method:'chat.group.joingroup',
					group_id:group_id,
					is_activity:true
				},function(result){
					if(callback)
					callback(result.result);
				})
			}
			
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Activitysecond", factory);
});